/***************************************************************************
 * Copyright (C) 2005 Global Biodiversity Information Facility Secretariat.
 * All Rights Reserved.
 *
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 ***************************************************************************/
package org.gbif.agi.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author trobertson
 */
@Entity
@Table(name="taxon")
public class Taxon {
	
	private Long id;
	private Long left;
	private Long right;
	private Taxon parent;
	private String name;
	private AGIDatasource agiDatasource;
	private List<Taxon> children;
	
	@Id
	@Column(columnDefinition="int")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(nullable=false)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToOne
	@JoinColumn(name="parent_id")
	public Taxon getParent() {
		return parent;
	}
	public void setParent(Taxon parent) {
		this.parent = parent;
	}
	
	@OneToMany
	@JoinColumn (name="parent_id",updatable=false, insertable=false)
	public List<Taxon> getChildren() {
		return children;
	}
	public void setChildren(List<Taxon> children) {
		this.children = children;
	}
	@Column(name="lft")
	public Long getLeft() {
		return left;
	}
	public void setLeft(Long left) {
		this.left = left;
	}
	@Column(name="rgt")
	public Long getRight() {
		return right;
	}
	public void setRight(Long right) {
		this.right = right;
	}
	@ManyToOne(optional=false)
	@JoinColumn(name="datasource_id")
	public AGIDatasource getAgiDatasource() {
		return agiDatasource;
	}
	public void setAgiDatasource(AGIDatasource agiDatasource) {
		this.agiDatasource = agiDatasource;
	}
	
}